package com.huaxin.hxcloud.work;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huaxin.hxcloud.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hebing on 2017/8/2.
 */

public class HxSignRecordTypeAdapter extends RecyclerView.Adapter {
    private       List<String>   mData;
    private       Context        mContext;
    private final LayoutInflater mInflater;

    public HxSignRecordTypeAdapter(Context context, List<String> flagTypes) {
        this.mContext = context;
        this.mData = flagTypes;
        mInflater = LayoutInflater.from(context);
    }

    public void setData(List<String> data) {
        mData = data;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_sign_type_des, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.mItemTypeTv.setSelected(true);
        viewHolder.mItemTypeTv.setText(mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData == null ? 0 : mData.size();
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_type_tv)
        TextView mItemTypeTv;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
